<?php
/**
 * CreateTime: 2023/4/14 15:55
 */

namespace App\Models\MeMediator;

use App\Consts\TableConsts\TableConsts;
use App\Models\BaseModelV2;

class MediationAgreementModel extends BaseModelV2
{
    protected $table = TableConsts::LAW_CASE_MEDIATION_AGREEMENT;

    protected $primaryKey = 'law_case_mediation_agreement_id';

    protected $fillable = [
        'law_case_mediation_agreement_id',
        'law_case_id',
        'file_id',
        'created_time',
        'owner_id',
    ];

    protected static function booted()
    {
     //   parent::booted(); // TODO: Change the autogenerated stub
    }


    public function getTheSameMonthAgreementCount(){
        // 获取本月第一天
        $firstDayOfMonth = date('Y-m-01 00:00:00');
        // 获取本月最后一天
        $lastDayOfMonth = date('Y-m-t 23:59:59');
        return $this->where('created_time','>=',$firstDayOfMonth)->where('created_time','<=',$lastDayOfMonth)->count();

    }

    public function getByLawCaseId(mixed $law_case_id, array $array = ["*"])
    {
        return $this->select($array)->where('law_case_id',$law_case_id)->first();
    }

}